package org.wtj.service.sys;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.wtj.entity.ResponsePageEntity;
import org.wtj.entity.sys.SysJobConditionEntity;
import org.wtj.entity.sys.SysJobEntity;
import org.wtj.mapper.BaseMapper;
import org.wtj.mapper.sys.SysJobMapper;
import org.wtj.service.BaseService;

import java.util.List;

/**
 * 岗位 服务层
 *
 * @author wang 该项目是知识星球：java突击队 的内部项目
 * @date 2025-03-06 21:50:53
 */
@Service
public class SysJobService extends BaseService<SysJobEntity,  SysJobConditionEntity> {

	@Autowired
	private SysJobMapper sysJobMapper;

	/**
     * 查询岗位信息
     *
     * @param id 岗位ID
     * @return 岗位信息
     */
	public SysJobEntity findById(Long id) {
	    return sysJobMapper.findById(id);
	}

	/**
     * 根据条件分页查询岗位列表
     *
     * @param sysJobConditionEntity 岗位信息
     * @return 岗位集合
     */
	public ResponsePageEntity<SysJobEntity> searchByPage(SysJobConditionEntity sysJobConditionEntity) {
		int count = sysJobMapper.searchCount(sysJobConditionEntity);
		if (count == 0) {
			return ResponsePageEntity.buildEmpty(sysJobConditionEntity);
		}
		List<SysJobEntity> dataList = sysJobMapper.searchByCondition(sysJobConditionEntity);
		return ResponsePageEntity.build(sysJobConditionEntity, count, dataList);
	}

    /**
     * 新增岗位
     *
     * @param sysJobEntity 岗位信息
     * @return 结果
     */
	public int insert(SysJobEntity sysJobEntity) {
	    return sysJobMapper.insert(sysJobEntity);
	}

	/**
     * 修改岗位
     *
     * @param sysJobEntity 岗位信息
     * @return 结果
     */
	public int update(SysJobEntity sysJobEntity) {
	    return sysJobMapper.update(sysJobEntity);
	}

	/**
     * 批量删除岗位对象
     *
     * @param ids 系统ID集合
     * @return 结果
     */
	public int deleteByIds(List<Long> ids) {
		List<SysJobEntity> entities = sysJobMapper.findByIds(ids);
		SysJobEntity entity = new SysJobEntity();
		return sysJobMapper.deleteByIds(ids, entity);
	}

	@Override
	protected BaseMapper getBaseMapper() {
		return sysJobMapper;
	}

}
